﻿@model MvcCmsProjectTracker.ViewModels.ProjectPriorityViewModel
@{
    int count = 0;
}
<div id="priorities">
    @if (Model.Priorities.Count > 0)
    { 
        <table id="priority-table">
            <tr>
                <th>
                </th>
                <th>
                    Priorities
                </th>
                <th>
                    Image
                </th>
            </tr>
            @foreach (var item in Model.Priorities)
            { <tr id="#row-@item.PriorityID ">
               <td>
                   @Ajax.ActionLink("Delete", "DeletePriority", new { id = item.PriorityID }, new AjaxOptions { HttpMethod="POST", UpdateTargetId = "priorities", OnFailure = "handleFailure", OnSuccess = "styleControls", Confirm = "Are you sure you want to delete this Priority?" })
               </td>
               <td>
                   @item.Name
               </td>
               <td style="text-align: center;">
                   <img src="@Url.Content(item.ImageUrl)" alt="" />
               </td>
           </tr>
            }
        </table>
    }
    @using (Ajax.BeginForm("AddPriority", "Project", new { id = Model.ProjectID }, new AjaxOptions { HttpMethod="POST", UpdateTargetId = "priorities", OnFailure = "handleFailure", OnSuccess = "styleControls" }))
    { 
        <p>
            <label for="name">
                Priority Name:</label>
            @Html.TextBox("priorityname", "")</p>
        <p>
            @foreach (string s in Model.ImagesUrls)
            {
                <input type="radio" name="imageurl" value="@s " @(count == 0 ? "checked=\"checked\"" : "")  /><img src="@Url.Content(s)" alt="" />         
                count++;
            }
        </p>
        <p>
            <input type="submit" value="Submit" /></p>
    }
    @Html.Partial("ControlsProjectTracker/Message", Model)
</div>
